1. Field of the Invention
This invention relates to the field of microprocessor-based processing systems, and, in particular, to paged data addressing methods.
2. Background Art
In microprocessor-based systems, a processor such as a central processing unit (CPU) of a personal computer, or a digital signal processor (DSP) used in more application specific systems, manipulates data based on coded instructions. The utility of the processor is dependent on the instruction set of the processor, i.e., those basic functions built into the processor architecture that are controlled by microcode. In order to increase the utility of a system, further functionality may be provided by the addition of peripherals.
Peripherals are devices that provide special purpose functions. Some examples of peripherals are analog-to-digital (ADC) and digital-to-analog (DAC) converters, control and status registers, and special purpose logic. Peripherals are typically accessed through registers. The processor accesses the peripheral registers like other locations within the system address space by specifying an appropriate address on an address bus, then reading or writing to the register through a data bus. The peripheral devices read and write to the respective peripheral registers continuously.
The addressing scheme of a processor-based system must accommodate the peripheral registers and all other addressable entities, such as data memory. However, a fixed address for peripheral registers places unwanted constraints on the system. External devices such as RAM and digital ASICs must work around the assigned and fixed address space of the peripheral registers. Alternative addressing methods are therefore desired.
Memory mapping is one method for modifying the way that a processor accesses memory. Techniques used for memory mapping in the prior art include memory management, expanded memory or memory banking, changeable configuration jumpers on adapters, and programmable hardware address decoding.
Memory management is a technique that involves assigning blocks of memory to different tasks running on the same computer. Hardware used for memory management can exist separately or may be present in the processor itself, as in the Intel(copyright) 80386 microprocessor. Memory management allows each application program to run in a virtual machine where memory is transparently mapped from unique physical addresses to virtual logical addresses, hiding the fact that other application programs exist.
Expanded memory or memory banking is a technique used with processors able to address only a limited address space. In the banking scheme, more memory is provided than the processor can physically address. Physical memory banks are enabled and disabled individually as needed using special xe2x80x9cbank selectxe2x80x9d hardware, thereby expanding the usable memory range.
Configuration jumpers, used frequently in personal computers, are hardware connectors that set up an I/O card to have a particular address space and respond to a particular set of control signals. Setting the jumpers is strictly a one-time operation, providing little addressing flexibility for the system once the setting operation is performed.
While examples of random access memory mapping exist in the prior art, peripheral hardware mapping exists in only a limited form. In one example, a series of AT controllers developed by Adaptec use one control bit to locate the address space of a device at one of two possible locations so that the device does not conflict with the address range of a second device. The control bit is intended to be set only once at initialization, and it is not possible to share data memory or alter the address setting thereafter.
Industry standard digital signal processors use paged data addressing methods. Paged data addressing relies upon a separate data page pointer to point to the currently accessible data memory page. The DSP can then access words within the page using a reduced address word. For instance, in a 64 k address space with a 128-word page size, the DSP can address the contents of the page with a smaller seven-bit address word rather than the complete sixteen-bit address word. The data page pointer provides the other nine bits of address information. This enables the processor to specify the seven-bit address within a sixteen-bit microinstruction word. The alternative requires that a microinstruction reserve a second word in program memory for every address related instruction to hold the complete sixteen-bit address.
Prior art methods of attaching peripherals to processors, including paged DSPs, consist of assigning a specific address to each peripheral. Access to the peripheral is always through the fixed address. The peripheral address can be in I/O or data memory space within the processor""s address space. However, I/O space is usually supported with simple instructions such as IN or OUT, whereas data memory space is supported by a rich set of instructions. In a paged data memory DSP system, data memory space is typically the most powerful from an instruction viewpoint.
FIG. 1 shows an example of a DSP-based servo predriver system with a peripheral register block and associated peripherals. The servo predriver system is used to control a voice coil motor for positioning an actuator arm and a spindle motor of a disk drive. In FIG. 1, digital signal processor 100 contains arithmetic logic units (ALUs) and other logic for manipulating and transferring data in the system. Also included within the processor is a block of internal memory 101, typically random access memory (RAM). This internal memory is separated into program memory and data memory, though this separation may be conceptual only. Also, the program memory may be implemented with programmable read-only memory (PROM) rather than RAM, in which case the microcode stored in program memory would be referred to as firmware, as opposed to software. The program memory stores the microcode instructions of the program controlling the operation of the processor, whereas the data memory provides storage for firmware or software variables and data the DSP is processing. For this example, the DSP contains 1,024 words of internal program memory and 544 words of internal data memory.
The address bus is sixteen bits wide to provide an address space of 64 k unique addresses. In this paged addressing system, the address space is separated into 512 data pages containing 128 unique addresses apiece. Thus, the nine most significant bits of the sixteen-bit address are determined by the chosen data page, and the seven least significant bits determine the chosen address within the data page. The data bus is also sixteen bits wide. The nine-bit data page value is stored in a data page register in memory as a pointer to the current data page. Microcode instructions enable the DSP to write data page pointer values to the data page register and thus change the current data page.
Address, control and data busses 125 are provided from DSP 100 for attachment of external devices such as external memory and I/O devices. The external devices are assigned addresses within the 64 k address space for paged access by the DSP. Wait state generator (WSG) 102 is coupled to DSP 100 via bus 124. Peripheral I/O register (PIO REG) 105 is coupled to DSP 100 through address bus 103 and data bus 104. Digital-to-analog converters 106 and 107 (DAC1 and DAC2) are coupled to PIO REG 105 through busses 115 and 116, respectively. Positioner circuit 108 and spindle circuit 109 are coupled to PIO REG 105 via bus 117. Spindle counter 111 and analog-to-digital converter 113 are coupled to PIO REG 105 through busses 120 and 121 respectively. Time base generator 112 and spindle DAC 114 (SPDAC) are coupled to PIO REG 105 via busses 118 and 119, respectively. Spindle counter 111 is coupled to spindle circuit 109 via bus 123. Servo/ADC logic 110 is coupled to PIO REG 105 through bus 126 and to ADC 113 through bus 122.
DSP 100 communicates with the peripherals through PIO REG 105. PIO REG 105 consists of a block of sixteen registers in this example, all mapped to interface with the peripherals of the system. These registers are continuously accessible by the peripherals, but are typically only accessed by the processor according to instructions in the microcode.
Time Base circuit 112 is provided for the generation of clock signals. A clock signal for the peripheral circuits is generated by dividing an externally supplied high frequency clock signal by a four-bit value stored in a clock control register within PIO REG 105.
WSG 102 simplifies the attachment of external program and data memory to the processing system. The processor""s memory space is separated into segments, each of which is assigned a wait state value. I/O space may be similarly assigned wait state values. Wait states are useful when the speed of the processor exceeds the access speed of the memory or I/O device the processor is trying to read or write. The processor cycles through the assigned number of wait states while the memory or device completes its relatively slower operation. The assigned wait state values may be stored as a wait state code in a wait state register within the internal memory of DSP 100.
In this example, there are several registers within PIO REG 105 for holding the ten-bit result of two""s complement ADC conversions from ADC 113. In a typical servo predriver application, ADC 113 receives position bursts from a servo demodulator and a voice coil motor current value (SOUT) sensed from a small resistor placed in series with the voice coil motor, in one example performing five conversions corresponding to four position bursts and one voice coil motor current value. ADC status bits in PIO REG 105 are polled to test conversion progress or, alternatively, a conversion complete interrupt may be used to notify the DSP that data is available.
The Servo/ADC Logic 110 controls the operation of ADC 113 according to ADC mode control bits stored in a servo control register within PIO REG 105. The different modes of the ADC operation differ in the method of starting the ADC conversion, the number of conversions performed, and the input source. For the example of FIG. 1, the selectable input sources are ADC0, ADC1, ADC2, ADC3, ADC4, ADC5, SOUT and VREF. VREF is a bandgap reference voltage provided by a reference circuit, and used as a voltage reference in other circuits such as Positioner Circuit 108. Table 1 lists the ADC conversion modes of this example.
DAC1106 and DAC2107 are two""s complement ten-bit voltage DACs for providing analog outputs to the servo predriver system based on the digital input received from DSP 100 via PIO REG 105. DAC2 is equipped with a switch for selecting from two reference voltage signals. A control bit within PIO REG 105 determines which signal is selected. In addition, for spindle motor current control, a twelve-bit pulse density DAC, SPDAC 114, provides an analog output signal based on a digital value passed through PIO REG 105 from DSP 100. The analog output (not shown) is provided to spindle circuit 109 to set the maximum spindle current.
Spindle circuit 109 includes a spindle motor current waveform generator, a phase error circuit and phase locked loop, MOSFET predrivers, and a delayed spindle brake circuit. The waveform generator drives the spindle motor windings with properly phased current waveforms. In run mode, the generator is clocked by the VCO output within the phase locked loop. During start mode, the generator is clocked by the ADVANCE bit in the spindle control register within PIO REG 105. As stated above, the output from SPDAC 114 controls the peak amplitude of the current waveform. A GAIN bit in PIO REG 105 is used to select between two possible peak current values corresponding to two peak voltage values across the sense resistors of each branch.
Spindle Counter 111 includes three counters for providing spindle speed and phase control. A first counter (spindle counter 1) is dedicated to measuring the period of a local spindle. Spindle mode bits within PIO REG 105 a reprogrammed so that the measurement period is based on the commutation of the spindle motor itself, as detected from the spindle VCO within Spindle Circuit 109, or from an external source.
Synchronized dual-spindle operation is supported with a master spindle counter (spindle counter 2) and a relative phase counter (spindle counter 3). The master spindle counter measures the period of the master spindle. The relative phase counter is started by the master spindle index pulse and stopped by the local spindle index pulse to generate a phase measurement. To assist in measuring phase for all angles, the relative phase counter can be preloaded with a number such that a two""s complement value centered at zero corresponds to the desired phase. Counter values are written to respective registers within PIO REG 105. Counter flag bits within PIO REG 105 are enabled to indicate to the DSP that a new counter value has been written to the respective register in PIO REG 105.
Spindle motor startup is implemented by the DSP. The DSP asserts an ADVANCE bit in the spindle control register within PIO REG 105, which in turn advances the spindle commutation counter a fraction of a commutation. During startup, the DSP provides an increasing frequency of ADVANCE pulses to accelerate the motor. When the motor has reached sufficent speed, the DSP enables normal mode via an ENABLE bit in the spindle control register and Spindle Circuit 109 assumes control of commutation.
Positioner Circuit 108 is an actuator predriver including amplifiers, a saturation detector, and crossover protection. The actuator predriver serves as a transconductance amplifier by driving four external MOSFETs in an H-bridge configuration. Class B operation is ensured by crossover protection circuitry between the amplifier outputs and the external MOSFETs, permitting only one MOSFET at a time in each leg of the H-bridge to be conducting. The crossover protection circuitry also applies a constant voltage across the voice-coil motor to retract the actuator arm at a constant velocity when the RETRACT bit in PIO REG 105 is set.
FIG. 5 is a peripheral I/O register map for PIO REG 105 of the example discussed above. Registers are labeled in the leftmost column in hexadecimal format from 0-9 and A-F. The register bits are specified by column from left to right with bit 15 on the left and bit 0 on the right.
Register 0 is the servo control register. In bit position 15, the FIFOMODE bit is used to alter the functionality of register 6. When the FIFOMODE bit is set high, register 6 is configured as a four word first-in first-out (FIFO) register. The DSP can write successive values into the FIFO (register 6), and the FIFO is read out to the DACs sequentially when triggered by an externally provided DACUPDATE signal.
The DACWRITEMODE bit in position 14 of register 0 controls the operation of DAC1 and DAC2. When the DACWRITEMODE bit is not asserted, the upper ten bits of data in registers 6 and 7 are converted by DAC1 and DAC2 respectively. When the DACWRITEMODE bit is asserted, the entire 16-bit word in register 6 is sent to DAC1 and DAC2 in the following manner: bit 15 is the sign bit for both DACs, bits 14-6 are sent to DAC1, bits 5-0 are sent to DAC2 as bit values 8-3 of the DAC word, and bit values 2-0 of the DAC word for DAC2 are written as 1-0-0 respectively.
Bit positions 13-10 of register 0 are used by the Servo/ADC Logic 110 to indicate when ADC conversions are complete for four of the five possible conversions in a typical cycle. Each bit indicates status for a separate conversion operation. Bit positions 9-7 store the ADC mode as outlined in Table 1. Bit position 6, labeled MARGIN, is used by a fault detection block (not shown) to alter the fault detection thresholds for the purpose of system margin testing. Bit position 5 is used to select between two reference voltages provided to DAC2, VREF provided internally and DAC2REF provided externally. Bit position 4 is used by the DSP to assert RETRACT mode for the Positioner Circuit 108. Bit position 3 is asserted by the Positioner Circuit 108 when saturation is detected in the current sense amplifier. Bit position 2 is used to enable the voice-coil motor circuitry of Positioner Circuit 108. Bit position 1 is used for DSP control of the start of ADC conversions in ADC 113. Bit position 0 is a status bit for indicating when ADC 113 is busy with a conversion operation.
Register 1, labeled ADC0/4, stores the conversion values for ADC 113 of two analog inputs, ADC0 and ADC4. Register 1 stores the conversion value from DAC1 when ADC 113 is in internal calibration mode. Register 2, labeled ADC1/5, similarly stores conversion values for ADC 113 from two analog inputs, namely ADC1 and ADC5, as well as the conversion value from DAC2 when in internal calibration mode. Register 3, labeled ADC2/VBG, stores the conversion value of analog input ADC2, and a conversion value of the internal bandgap reference voltage input VREF from ADC 113. Registers 4 and 5, labeled ADC3 and SOUT respectively, store the conversion values for analog inputs ADC3 and spindle current sense value SOUT for ADC 113. The DSP writes the digital input conversion values for DAC1 and DAC2 into registers 6 and 7, respectively, subject to FIFOMODE and DACWRITEMODE bits described above. All of the above ten-bit conversion values for registers 1-7 are stored in register bits 6-15, with the most significant bit in bit position 15.
Register 8 stores sleep control bits in positions 7 and 8. Bit positions 6-3 hold a division factor for dividing down the master clock in Time Base circuit 112 to generate the peripheral clock. Bit positions 2-0 contain flag values for each of the three counters in Spindle Counter circuit 111. Register 9 is reserved as a test word storage position.
Register A stores spindle control information for circuit portions 108-111. Bit positions 15-14 contain multiplexer control values for selecting between internal and external spindle counter index inputs, and divided frequency or undivided frequency inputs. Bit positions 13-12 contain counter mode control values for selecting the input and start and stop functions of the relative phase counter of Spindle Counter circuit 111. Bit positions 11-8 contain a divisor value between one and fifteen for dividing the frequency of an input to spindle counter 1. Bit positions 7-5 contain clock selection bits for selecting between two possible clock signals for each counter within Spindle Counter circuit 111. Bit positions 4-3 contain spindle circuit reset and enable bits. Bit position 2 contains a power control bit for disabling power to spindle circuit drive amplifiers. Bit position 1 contains a GAIN control bit for selecting between two possible spindle current amplitude profiles. Bit position 0 stores the ADVANCE bit used by the DSP to control spindle commutation during startup.
Register B stores the twelve-bit digital input value for SPDAC 114 in bits 14-3, with the most significant bit in bit position 14. Registers C and D store fifteen-bit counter values from spindle counters 1 and 2 within Spindle Counter circuit 111. The fifteen-bit counter values are stored in bit positions 14-0 with the most significant bit in position 14. Register E stores the sixteen-bit counter value, including a sign bit, for spindle counter 3. Register F stores a sixteen-bit preload offset value for spindle counter 3. In registers E and F, the sign bit is stored at position 15 with the most significant bit at position 14.
In the above peripheral register example, register 0, bits 0, 3 and 10-13 and register 8, bits 0-3 are peripheral status bits and may be implemented as xe2x80x9cread onlyxe2x80x9d registers with respect to the DSP. Similarly, registers 1-5 and C-E represent peripheral outputs that may also be xe2x80x9cread-only.xe2x80x9d Other registers are either peripheral control registers or peripheral input registers into which the DSP may write. The sixteen peripheral registers within PIO REG block 105 must be assigned to sixteen separate address locations in the address space to be uniquely addressable. Typically, however, the peripheral registers are grouped together in consecutive address locations for simplicity.
Peripheral registers are typically located in the processor""s address space on a different page than the data memory the microcode program is primarily accessing, i.e. the page or pages wherein the firmware variables reside. Because the peripheral register location is not on the same page as the current data memory used by the program, access to the peripheral register by the processor requires an intermediate data page register or auxiliary register loading operation. For example, a transfer of data from data memory to a peripheral register requires (1) an initial programming or loading of the data page register with the initial data page pointer value for the data memory containing the data value for transfer, (2) a DSP read of the data value, (3) an intermediate programming of the data page register to access the data page containing the peripheral registers, (4) a DSP transfer to the peripheral register, and (5) usually a reloading of the data page register back to the initial data page pointer value. These actions require execution of DSP instructions and therefore lower performance. This type of data transfer method is referred to as xe2x80x9cDirect Mode PIO Access.xe2x80x9d
FIG. 2 is a flow diagram of an example of a direct mode PIO data transfer between internal data memory and a peripheral. In the example, the operation performed consists of: (1) reading a peripheral status register indicating when an ADC register may be read, (2) reading a peripheral ADC register and copying the register value into internal data memory, and (3) writing an internal data memory value to a DAC register.
The direct mode access begins in block 201 where the data page pointer is loaded into the data page register. This act consists of setting the current data page via the data page pointer in the data page register so that the desired memory locations are accessible. In block 201, the data page pointer value loaded is for that data page containing the location of the PIO register block. In the following block 202, the processor reads the status register.
In block 203, based on the read operation in block 202, a test is performed to determine whether the AD_READY bit (e.g. xe2x80x9cADC3 Donexe2x80x9d) is set in the PIO status register, indicating that the ADC PIO register contains a valid value. If the AD_READY bit is not set, thereby indicating that the ADC is not yet ready, the operation returns to block 202 and reads the status register again. When the test in block 203 confirms that the AD_READY bit is set, the operation proceeds to block 204 wherein the processor reads the ADC PIO register. Once the ADC PIO register is read, in block 205, the data page pointer is reloaded in the data page register so that the internal data memory is once again accessible. In block 206, the ADC value is stored in data memory in the selected page.
In block 207, the processor retrieves a value from data memory for loading into a DAC. To access the DAC PIO register, in block 208, the data page register is loaded with the data page pointer value for the page containing the PIO register block. In block 209, the processor writes the retrieved value into the DAC PIO register.
As illustrated in FIG. 2, in direct mode, the PIO register block must first be made accessible by setting the data page pointer in the data page register. Once the ADC is read, the data page register containing the data page pointer must be reloaded so that the internal data memory is accessible. One drawback to direct mode transfer operations is that the data page register must be frequently reloaded to switch between internal data memory and PIO register space.
An assembly code fragment implementing the direct mode operation discussed in FIG. 2 follows. The assembly instructions are consistent with the instruction set of a TMS32C025(trademark) code compatible DSP.
As illustrated above, nine instructions are required to accomplish the example operation using direct mode PIO access.
Some DSPs offer auxiliary registers to assist in page addressing by preloading a specified auxiliary register pointer and making use of xe2x80x9cnext auxiliary pointerxe2x80x9d instruction code operands in what is called xe2x80x9cIndirect Mode PIO Access.xe2x80x9d However, when auxiliary registers (ARs) are used to hold the peripheral address, one of the special purpose auxiliary registers must be dedicated. When multiple peripherals exist, each requires a separate AR. Since there are only a few ARs, dedicating them is not possible, and, therefore, direct page loading is necessary.
FIG. 3 is a flow diagram of the same example operation of FIG. 2, now implemented with an auxiliary register for indirect mode PIO access. Indirect mode relies upon auxiliary registers that are loaded with the complete address of the addressed peripheral register. In FIG. 3, indirect mode access begins in block 301 wherein the processor loads the data page register with the selected internal memory data page pointer value. In subsequent block 302, the processor loads the auxiliary register with a value that points to the location of the PIO status register. In block 303, the auxiliary register is selected as the active pointer register since only one may be active at a time. All references to the ADC are considered indirect because references to the ADC do not directly call out the address to the ADC. Instead, references to the ADC call out an auxiliary register which is then read to provide the address. After the pointer has been selected, in block 304, the processor reads the status register by means of the pointer.
A test of the status bit is made in block 305 to determine if the ADC is ready. If the ADC is not ready, the process returns to block 304 to read the status register via the pointer again. If the ADC is ready, as determined by the test in block 305, the auxiliary register is loaded in block 306 with the pointer value for the ADC PIO register. In block 307, the processor reads the ADC PIO register using the pointer stored in the auxiliary register. Then, in block 308, the processor stores the ADC value into the internal data memory using the data page pointer specified in block 301.
In block 309, the processor loads the auxiliary register with the pointer value for the DAC PIO register. In block 310, the processor retrieves the data memory value from internal data memory using the data page pointer. In subsequent block 311, the processor writes the retrieved value into the DAC PIO register using the pointer value in the auxiliary register.
Indirect mode has the disadvantage of requiring each PIO register address to be loaded by an extra instruction into an auxiliary register prior to access. Though the DSP provides simple means for incrementing or decrementing the auxiliary register pointer content after an access operation, these pointer operations are intended for accessing arrays of memory. Peripheral registers are typically special functions and it is rare that successive PIO accesses can take advantage of simple post increment or decrement operators.
An assembly code fragment implementing the indirect mode operation discussed in FIG. 3 follows.
As shown above, eleven instructions are required to accomplish the example operation using indirect mode PIO access.
The present invention is a method and apparatus for providing relocatable overlaid peripheral paging. The present invention provides improved and flexible peripheral register access for microprocessor-based applications such as digital signal processing systems which implement paged data addressing. Unnecessary page selection is eliminated to enhance processing speed and to provide peripheral addressing flexibility. The present invention also provides a performance improvement by allowing peripheral registers to share the same page as data. When the peripheral register shares the same page as data, intermediate data page pointer loading (direct or indirect through auxiliary registers) is unnecessary. Therefore, the microprocessor instructions necessary to transfer data between data memory and peripherals are reduced. Due to the reduction in the number of instructions required for data transfer, the processor runs more efficiently and consumes less program memory.
The present invention provides a means of flexibly locating the data page assigned to the peripheral registers. External hardware contentions are eliminated because the peripheral registers can be relocated anywhere in the system address space. Hardware design is therefore much more flexible. Further, because the present invention allows peripheral registers to overlay internal data memory, data transfers can be carried out between data memory and peripherals using the same data page pointer. No intermediate pointer loading operations are required and memory operations to the peripheral registers can be carried out at maximum speed.
The present invention allows peripheral registers to overlay data memory in a manner that permits the overlaid memory to be recovered and used for other purposes. Processor program code can be designed to overlay internal data memory with a peripheral register while performing data transfers between the data memory and the peripheral register. The overlaid data memory is not accessible while it is overlaid. Then, after completing transfers, the peripheral register can be relocated elsewhere so that the underlying internal data memory is recovered. The underlying data memory is not disturbed when writing to the overlaying peripheral register.
The present invention offers considerable advantages, high levels of integration, and is an effective solution to supporting large numbers of peripheral registers.